// 卡牌数据
let cards = [

  {
    id: 'xr',
    type: 'attack',
    title: '袭扰',
    description: '扣除敌方 1 点<b>物资</b>',
    note: ' &#171;The finest machine Man ever created!&#187;',
    play (player, opponent) {
     
      opponent.food -= 1
    },
  },
  {
    id: 'pj',
    type: 'attack',
    title: '破击',
    description: '增加己方 1 点<b>物资</b><br>扣除敌方 2 点<b>血量</b>',
    note: '&#171;Ready your bows! Nock! Mark! Draw! Loose!&#187;',
    play (player, opponent) {
      player.food += 1
      opponent.health -= 2
    },
  },
  {
    id: 'fj',
    type: 'attack',
    title: '伏击',
    description: '扣除敌方 1 点<b>物资</b><br>扣除敌方 1 点<b>血量</b>',
    note: 'Knights may be even more expansive than their mount.',
    play (player, opponent) {
      opponent.food -= 1
      opponent.health -= 1
    },
  },
  {
    id: 'xj',
    type: 'attack',
    title: '袭击',
    description: '扣除己方 1 点<b>物资</b><br>扣除敌方 2 点<b>血量</b>',
    play (player, opponent) {
      // player.skipTurn = true
      player.health -= 1
      opponent.health -= 2
    }
  },
  {
    id: 'mqjf',
    type: 'special',
    title: '麻雀技法',
    description: '扣除敌方 1 点<b>血量</b>',
    note: 'Send your disposable men to a certain death.',
    play (player, opponent) {
      
      opponent.health -= 1
    },
  },
  {
    id: 'wk',
    type: 'special',
    title: '围困',
    description: '扣除敌方 1 点<b>物资</b><br>扣除敌方 1 点<b>血量</b>',
    play (player, opponent) {
      opponent.food -= 1
      opponent.health -= 1
    },
  },
  {
    id: 'fjj',
    type: 'special',
    title: '反间计',
    description: '扣除敌方 1 点<b>物资</b><br>扣除敌方 1 点<b>血量</b>',
    note: 'This is not without consequences on the moral and energy!',
    play (player, opponent) {
      opponent.food -= 1
      opponent.health -= 1
    }
  },
  {
    id: 'sl',
    type: 'special',
    title: '狩猎',
    description: '扣除敌方 2 点<b>血量</b>',
    note: '&#171;One should be patient to grow crops.&#187;',
    play (player, opponent) {
      // player.skipTurn = true
      opponent.food -= 2
    },
  },
  {
    id: 'lcxx',
    type: 'support',
    title: '粮草先行',
    description: '增加己方 2 点<b>物资</b>',
    play (player, opponent) {
      player.food += 2
    }
  },
  {
    id: 'zy',
    type: 'support',
    title: '治愈',
    description: '回复己方 2 点<b>血量</b>',
    note: 'Send someone you trust poison the enemy granary.',
    play (player, opponent) {
      player.health += 2
      
    },
  },
  {
    id: 'yjxb',
    type: 'support',
    title: '偃甲息兵',
    description: '增加己方 2 点<b>物资</b><br>回复己方 1 点<b>血量</b>',
    note: '&#171;Magic isn\'t for kids. You fool.&#187;',
    play (player, opponent) {
      player.food += 2
      // player.skipTurn = true
      player.health += 1
    },
  },
  {
    id: 'yydl',
    type: 'support',
    title: '以逸待劳',
    description: '增加己方 1 点<b>物资</b><br>回复己方 2 点<b>血量</b>',
    note: 'Pray in the chapel, and hope someone will listen.',
    play (player, opponent) {
      // Nothing happens...
      player.food += 1
      player.health += 2
    },
  },
  {
    id: 'pfcz',
    type: 'max',
    title: '破釜沉舟',
    description: '扣除敌方 3 点<b>血量</b><br>扣除敌方 2 点<b>物资</b>',
    play (player, opponent) {
     
      opponent.food -= 2
      opponent.health -= 3
    },
  },
  {
    id: 'jysz',
    type: 'max',
    title: '决一死战',
    description: '扣除己方 1 点<b>物资</b><br>扣除己方 1 点<b>血量</b><br>扣除敌方 2 点<b>物资</b><br>扣除敌方 4 点<b>血量</b>',
    play (player, opponent) {
      player.food -= 1
      player.health -= 1
      opponent.food -= 2
      opponent.health -= 4
    },
  },
]

cards = cards.reduce((map, card) => {
  card.description = card.description.replace(/\d+\s+<b>.*?<\/b>/gi, '<span class="effect">$&</span>')
  card.description = card.description.replace(/<b>(.*?)<\/b>/gi, (match, p1) => {
    const id = p1.toLowerCase()
    return `<b class="keyword ${id}">${p1} <img src="svg/${id}.svg"/></b>`
  })
  map[card.id] = card
  return map
}, {})
//这里显示每一种牌有几张
let pile = {
  mqjf: 3,
  wk: 3,
  xr: 3,
  pj: 2,
  fj: 3,
  xj: 2,
  fjj: 3,
  sl: 3,
  lcxx: 3,
  pfcz: 1,
  zy: 2,
  yjxb: 2,
  yydl: 2,
  jysz: 1,
}
